//
//  EvaluationViewController.m
//  WheatPlan
//
//  Created by giantumbrella on 15/5/21.
//  Copyright (c) 2015年 IOSTeam. All rights reserved.
//

#import "EvaluationViewController.h"
#import "CommonMacro.h"
#import "CatchViewController.h"
#import "ParentViewController.h"
#import "ChildrenViewController.h"
#import "InterpretationViewController.h"
#import "UserDAL.h"
#import "TestQuestionsViewController.h"
#import "AppointmentViewController.h"

@interface EvaluationViewController (){
    
    
    NSArray * arr;
    
}

@end

@implementation EvaluationViewController

-(void)viewDidAppear:(BOOL)animated{
    
    self.tabBarController.tabBar.selectedImageTintColor = [GetFileModel colorWithHexString:@"#44afd7" alpha:1];
    if ([BabyManager shareInstance].babyId == nil) {
        
        [self.tabBarController setSelectedIndex:0];
        [self ShowProgressHUDwithMessage:@"请先添加宝宝"];
        
    }
    

}
- (void)viewDidLoad {
    [super viewDidLoad];

    //设置导航栏头文字
    self.navigationItem.title = @"发现";
    //设置导航栏背景颜色
    [self.navigationController.navigationBar setBarTintColor:[GetFileModel colorWithHexString:@"#44afd7" alpha:1]];
    //设置导航栏字体颜色
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
    
    _evaluationTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
    _evaluationTableView.delegate = self;
    _evaluationTableView.dataSource = self;
//    _evaluationTableView.separatorInset = UIEdgeInsetsZero;
//    _evaluationTableView.separatorColor = [UIColor blueColor];
    _evaluationTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_evaluationTableView];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark--- tableViewDelegate 每个区的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section==0) {
        return 4;
        
    }else{
        
        return 3;
    }
}

#pragma mark--- tableViewDelegate 区尾的高度

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 0;
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (indexPath.row == 0) {
        
        return  33;
 
        

        
    }else{
        
        return  42;

        
    }
    
    
    
}


#pragma mark--- tableViewDelegate cell

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *NOTIFY = @"cell";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:NOTIFY];
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NOTIFY];
        
        
        if (indexPath.row!=0) {
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            
        } else {
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.backgroundColor = UIColorWithRGBA(240, 239, 245, 1);
            
        }
        
        if (indexPath.section == 2) {
            
            //隐藏多于分割线
            _evaluationTableView.tableFooterView = [[UIView alloc]init];
            
        }
        
        
        if (indexPath.row !=0) {
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, _evaluationTableView.rowHeight-1, SCREEN_WIDTH, 1)];
            view.backgroundColor = UIColorWithRGBA(229, 229, 231, 1);
            [cell addSubview:view];

        }
        
        
        if (indexPath.section == 0 ) {
            
            if (indexPath.row == 0) {
                
                UILabel * lab1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 33)];
                
                lab1.text = @"      成长观察";
                lab1.textColor = [UIColor grayColor];
                lab1.font = [UIFont systemFontOfSize:14];
                [cell addSubview:lab1];
                
                UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4, 0, 200, 33)];
                lab.textColor = [UIColor grayColor];
                lab.text = @" （多维度了解你的宝宝）";
                lab.font = [UIFont systemFontOfSize:12];
                lab.textAlignment = NSTextAlignmentLeft;
                cell.userInteractionEnabled = NO;
                [cell addSubview:lab];
                
                
            } else if(indexPath.row ==1)
            {
                
                cell.textLabel.text = @"  敏感期观察";
                cell.textLabel.font = [UIFont systemFontOfSize:15];
                
                
            }else if (indexPath.row ==2){
                cell.textLabel.text = @"  感觉统合观察";
                cell.textLabel.font = [UIFont systemFontOfSize:15];
                
            }else{
                cell.textLabel.text = @"  智能特征观察";
                cell.textLabel.font = [UIFont systemFontOfSize:15];
                
            }
            
            
        }
        if(indexPath.section == 1){
            
            if (indexPath.row == 0) {
                
                UILabel * lab1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 33)];
                
                lab1.text = @"      成长报告";
                lab1.textColor = [UIColor grayColor];
                lab1.font = [UIFont systemFontOfSize:14];
                [cell addSubview:lab1];
                
                UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4, 0, 200, 33)];
                lab.textColor = [UIColor grayColor];
                lab.font = [UIFont systemFontOfSize:14];
                lab.textAlignment = NSTextAlignmentLeft;
                lab.text = @" （宝宝成长观察报告）";
                cell.userInteractionEnabled = NO;
                
                [cell addSubview:lab];
            } else if(indexPath.row ==1)
            {
                cell.textLabel.text = @"  家长观察报告";
                cell.textLabel.font = [UIFont systemFontOfSize:15];
                
                
            }else if (indexPath.row ==2){
                
                cell.textLabel.text = @"  老师观察报告";
                cell.textLabel.font = [UIFont systemFontOfSize:15];
                
            }
            
            
        }
        if (indexPath.section == 2) {
            if (indexPath.row == 0) {
                
                
                UILabel * lab1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 33)];
                
                
                lab1.text = @"      报告解读";
                lab1.textColor = [UIColor grayColor];
                lab1.font = [UIFont systemFontOfSize:14];
                [cell addSubview:lab1];
                
                UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4, 0, 200, 33)];
                lab.textColor = [UIColor grayColor];
                lab.textAlignment = NSTextAlignmentLeft;
                lab.font = [UIFont systemFontOfSize:14];
                lab.text = @" （专家解读成长观察报告）";
                cell.userInteractionEnabled = NO;
                
                [cell addSubview:lab];
            } else if(indexPath.row ==1)
            {
                cell.textLabel.text = @"  同城解读报告";
                cell.textLabel.font = [UIFont systemFontOfSize:15];
                
                
            }else if (indexPath.row ==2){
                
                cell.textLabel.text = @"  上门解读报告";
                cell.textLabel.font = [UIFont systemFontOfSize:15];
                
                
            }
            
            
        }

        
    }
    
    
    return cell;
    
    
    
    
    
    
    
}
#pragma mark--- tableViewDelegate 有几个区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
    
}
#pragma mark--- tableViewDelegat 点击方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    
    if
        (indexPath.section == 0 )
    {

        if (indexPath.row ==1)
        {
     

            TestQuestionsViewController * testVC = [[TestQuestionsViewController alloc]init];
            testVC.typeID = [NSString stringWithFormat:@"%d",(indexPath.row -1)];
//            testVC.situationID =@"";
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:testVC];
            [self presentViewController:nav animated:YES completion:nil];

            
        }
        else if (indexPath.row ==2)
        {
            
            CatchViewController * cat = [[CatchViewController alloc]init];
            cat.typeID = @"1";
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:cat];
            [self presentViewController:nav animated:YES completion:^{
                
                
                
                
            }];
            
        }
        else
        {
            
            
            TestQuestionsViewController * testVC = [[TestQuestionsViewController alloc]init];
            testVC.typeID = @"2";
            testVC.situationID =@"";
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:testVC];
            [self presentViewController:nav animated:YES completion:nil];
            
        }
        
        
    }
    
    if
        (indexPath.section ==1)
    {
        if
            (indexPath.row == 1)
        {
            
            ParentViewController * par = [[ParentViewController alloc]init];
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:par];
            
            
            [self presentViewController:nav animated:YES completion:^{
                
                
                
                
                
            }];
            
        }
        else
            if
                (indexPath.row == 2)
            {
            
            
                ChildrenViewController * chi = [[ChildrenViewController alloc]init];
                UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:chi];
                
                
                [self presentViewController:nav animated:YES completion:^{
                    
                    
                    
                    
                    
                }];
            
        }
        
        
        
        
        
        
    }
    
    
    
    
    if (indexPath.section ==2) {
        if (indexPath.row == 1) {
            
                       
            InterpretationViewController * inter = [[InterpretationViewController alloc]init];
            
            
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:inter];
            
            
            [self presentViewController:nav animated:YES completion:^{
                
                
                
                
                
            }];
            
            
        }else{
            
            AppointmentViewController * testVC = [[AppointmentViewController alloc]init];
            UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:testVC];
            [self presentViewController:nav animated:YES completion:nil];

            
            
        }
    }
    
    
    
    
    
}
- (void)ShowProgressHUDwithMessage:(NSString *)msg
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = msg;
    hud.dimBackground = NO;
    hud.removeFromSuperViewOnHide = YES;
    [hud hide:YES afterDelay:1];
}

@end
